<template>

    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-warn"></i> 任务管理</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
           
        </div>
    

    <el-table :data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
    style="width: 100%">
    <el-table-column label="Date"prop="date"></el-table-column>
    <el-table-column label="Name" prop="name"></el-table-column>
    <el-table-column align="right">
      <template slot="header" slot-scope="scope">
        <el-input v-model="search" size="mini" placeholder="输入关键字搜索"/>
      </template>
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
        <el-button size="mini"  type="danger"@click="handleDelete(scope.$index, scope.row)">Delete</el-button>
      </template>
    </el-table-column>
  </el-table>
  <el-pagination @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="pageNumber"
                  :page-sizes="[10, 20, 30, 40]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="this.totalRow">
  </el-pagination>
  </div>
</template>

<script>
import {getTaskPageList} from '@/api/back/task'
    export default {
        data: function(){
            return {
              tableData: [],
              search: '',
              pageNumber: 1,//当前页
              pageSize: 10,//每页大小
              totalRow: 0,//总条数
              totalPage: 0,//总页数
            }
        },
        methods: {
          handleEdit(index, row) {
            console.log(index, row);
          },
          handleDelete(index, row) {
            console.log(index, row);
          },
          //分页点击方法
          handleSizeChange (val) {
            // console.log(`每页 ${val} 条`);
            this.pageSize = val
            var params = {
              pageNumber: this.pageNumber,
              pageSize: this.pageSize
            }
            this.getPageList(params)
          },
          handleCurrentChange (val) {
            // console.log(`当前页: ${val}`);
            this.pageNumber = val
            var params = {
              pageNumber: this.pageNumber,
              pageSize: this.pageSize
            }
            this.getPageList(params)
          },
          // 获取分页列表
          getPageList(params){
            getTaskPageList('/task/findpagelist', params,'post','taskcenter').then(
              res =>{
                if(res.code==200){
                  this.tableData = res.data.list
                  this.totalRow = res.data.totalRow
                }else{
                  this.$message.false(res.message);
                }
              }
            )
          }
        },
        created(){
         var params = {
            pageNumber: this.pageNumber,
            pageSize: this.pageSize
         }
         this.getPageList(params)
        }
    }
</script>

<style scoped>
h1{
    text-align: center;
    margin: 30px 0;
}
p{
    line-height: 30px;
    margin-bottom: 10px;
    text-indent: 2em;
}
.logout{
    color: #409EFF;
}
</style>